<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<%@ include file="/common/metaInput.jsp"%>
<script  type="text/javascript" src="${ctx}/js/jsp/comm.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.form.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery.MultiFile.js"></script>
<script type="text/javascript">
	var basic_Url = "${ctx}/attach/upload";
	var grid;
	var options = {
			type:"POST",
	    	dataType:"json",
	    	url:basic_Url + "/toSaveFileUpload.do",
	    	success:function(data){
	    		var manager = $("#fileTable").ligerGetGridManager(); 
	    		for(var i=0;i<data.length;i++){
	    			//alert(data[i].id);
	    			manager.addRow({
	    				id : data[i].id,
	    				fileName : data[i].fileName,
	    				fileSize : data[i].fileSize,
	    				fileContentType : data[i].fileContentType
	    			});
	    		}
	    		
	    		$("#filename").val("");
	    	},
	    	error: responseCallback
			
	};
	$(function(){
			grid = $("#fileTable").ligerGrid({
	        columns: [
	                  { display: '附件ID', name: 'id', width: 145 ,hide : 1},
	                  { display: '附件名称', name: 'fileName', width: 145 },
	                  { display: '附件大小', name: 'fileSize', width: 145 },
	                  { display: '附件类型', name: 'fileContentType', width: 145 }
	                 ], 
	        usePager: true,pageSize:30,
	        parms:[{ name: 'projectId', value: '${projectId}'}],
	        url : basic_Url+"/getCanFileUploadByProjectId.do",
	        width: "100%", 
	        height:"98%", 
	        enabledEdit : true,
	        checkbox: true,
	        isScroll: true
	      });
		$("#pageloading").hide();
		
		
		//初始化ajaxForm组件
		$('#inputForm').ajaxForm(options);
	});
	
	function getSelected(){
		var rows = grid.getCheckedRows();
		 return rows;
	}
	
	function Close(){
		CloseDialog();
	}
	
	function responseCallback(){
		alert("附件上传失败！");
     	/* var attachType = submitInputId.split("_")[1];
     	alert("上传的附件不能大于10M,请您重新选择！");
     	$("#file_"+attachType).remove();
     	$("#"+attachType+"Form_image_div").hide();
     	$('#momentSaveBtn').attr('disabled',false);
		$('#nextStepBtn').attr('disabled',false);
     	var newFileHtml = appendInputFileHtml(attachType);
     	$("#"+attachType+"_input_div").append(newFileHtml); */
	}
	
	function fileUploadChange(){
		$("#inputForm").submit();
	}
	
	</script>

</head>
<body>
	<form id="inputForm" name="inputForm" method="post" action="${ctx}/yd/attach/upload/toSaveFileUpload.do" enctype ="multipart/form-data">
	<div class="pageContent">
		<div class="panel">
			<table class="TableBlock" align="center">
				<tr>
   		        	<td>选择文件:</td>
   		            <td>
   		                <input type="file" style="width : 200px" id="filename" name="filename" onchange="fileUploadChange();"/>
   		            </td>
   		        </tr>
			</table>
		</div>
		<div class="formBar">
			
		</div>
	</div>
	</form>

	<div id="fileTable"></div>
     
</body>
</html>